﻿namespace 并发处理.Datas
{

    public class CompanyRepository
    {
        private static List<Company> companies = new List<Company>()
        {
            new Company() { Id = 1, Name = "阿外巴巴", Address = "杭州", CreateTime = DateTime.Now, LastModify = DateTime.Now },
            new Company() { Id = 2, Name = "狗东", Address = "北京", CreateTime = DateTime.Now, LastModify = DateTime.Now },
            new Company() { Id = 3, Name = "千度", Address = "北极", CreateTime = DateTime.Now, LastModify = DateTime.Now },
            new Company() { Id = 4, Name = "疼训", Address = "深圳", CreateTime = DateTime.Now, LastModify = DateTime.Now },
        };
        public static Company FindById(int id)
        {
            return companies.FirstOrDefault(item => item.Id.Equals(id));
        }

        public static Company Update(Company company)
        {
            var aa = companies.FirstOrDefault(item => item.Id.Equals(company.Id));
            aa.Name = company.Name;
            aa.Address = company.Address;
            aa.LastModify = DateTime.Now;
            return aa;
        }
    }

    public class BaseEntity
    {
        public int Id { get; set; }
        public DateTime LastModify { get; set; }
    }
        public class Company:BaseEntity
    {
        public string Name { get; set; }
        public string Address { get; set; }
        public DateTime CreateTime { get; set; }
      
    }
}
